package com.yc.blog.dao.impl;

import java.util.List;

import com.yc.blog.bean.AdminInfo;
import com.yc.blog.dao.DBHelper;
import com.yc.blog.dao.IAdminInfoDao;

/**
 *  后台管理员数据模型层实现
 * @author yy
 * date 2020年8月12日
 * QQ:1464080002
 */
public class AdminInfoDaoImpl implements IAdminInfoDao{

	@Override
	public AdminInfo login(String aname, String pwd) {
		DBHelper db = new DBHelper();
		String sql = "select aid, aname, photo from admininfo where aname=? and pwd=md5(?)";
		return db.find(AdminInfo.class, sql,aname,pwd);
	}

	@Override
	public int add(String aname, String pwd, String photo) {
		DBHelper db = new DBHelper();
		String sql = "insert into admininfo values(0,?,md5(?),?)";
		return db.update(sql, aname,pwd,photo);
	}

	@Override
	public List<AdminInfo> findAll() {
		DBHelper db = new DBHelper();
		String sql = "select aid, aname, photo from admininfo order by aid desc";
		return db.finds(AdminInfo.class, sql);
	}

	
}
